//
//  XianKeyboardLianXiViewController.swift
//  CKC
//
//  Created by 张振东 on 2016/10/25.
//  Copyright © 2016年 ZZD. All rights reserved.
//

import UIKit

class XiaoKeyboardLianXiViewController: UIViewController,UITextFieldDelegate,ZSDSetPasswordViewDelegate,SheZhiLabelYangShiViewControllerDelegate {

    
    //获取模拟器或者真机的宽度和高度
    let screenWidth = UIScreen.main.bounds.width
    let screenHeight = UIScreen.main.bounds.height
    var navigationHeight:CGFloat?
    
    //定义一个变量,用于存储模式类别
    var moShiLeiBie:String?

    //定义一个变量,用于存储传递过来的分钟值
    var fenZhongZhi:String?
    
    //设置按钮
    var sheZhiBtn:UIButton?
    
    //定义一个变量,用于保存传递过来的indexPath.row
    var indexPathDianRow:Int = 0
    
    var indexPathRow:Int = 0
    
    //定义一个变量,用于存储设置lable边框形状的indexPathDianRow
    var bianKuangXingZhuangIndexPathDianRow:Int = 0
    
    //定义三个ImageView
    var zanTingImageView:UIImageView?
    var chaKanJieGuoImageView:UIImageView?
    var jieShuImageView:UIImageView?
    
    //定义两个View对象
    var firstFenGeXianView:UIView?
    var secondFenGeXianView:UIView?
    
    //定义三个按钮
    var zanTingBtn:UIButton?
    var chaKanJieGuoBtn:UIButton?
    var jieShuBtn:UIButton?
    
    //定义一条横线UIView
    var hengXianView:UIView?
    
    //创建8个UILabel对象
    var zhengQueShuLabel:UILabel?
    var zhengQueShuLabelValue:UILabel?
    
    var zhengQueLvLabel:UILabel?
    var zhengQueLvLabelValue:UILabel?
    
    var shiJianLabel:UILabel?
    var shiJianLabelValue:UILabel?
    
    var suDuLabel:UILabel?
    var suDuLabelValue:UILabel?
    
    //定义三个UIView,用于分割成四个模块
    var leftView:UIView?
    var middleView:UIView?
    var rightView:UIView?
    
    //定义一条横线UIView
    var secondHengXianView:UIView?
    
    //定义6个UIlabel对象,用于存储随机生成的6个数字
    var firstLabel:UILabel?
    var secondLabel:UILabel?
    var thirdLabel:UILabel?
    var fourthLabel:UILabel?
    //定义6个UITextField对象,用于存储用户输入的值
    var firstTextFieldValue:UITextField?
    var secondTextFieldValue:UITextField?
    var thirdTextFieldValue:UITextField?
    var fourthTextFieldValue:UITextField?
    
    //定义一个变量,用于存储正确数
    var zhengQueShu:Int = 0
    
    //定义一个类似支付宝的输入view
    var inputViews:ZSDSetPasswordView?
    
    //自己制作键盘,定义一个UIview对象
    var jianPanView:UIView?
    
    //定义11个按钮分别为0,1,2,3,4,5,6,7,8,9,完成
    var oneBtn:UIButton?
    var twoBtn:UIButton?
    var threeBtn:UIButton?
    var fourBtn:UIButton?
    var fiveBtn:UIButton?
    var sixBtn:UIButton?
    var sevenBtn:UIButton?
    var eightBtn:UIButton?
    var nineBtn:UIButton?
    var dianBtn:UIButton?
    var lingBtn:UIButton?
    
    //创建第一层的三个label对象
    var firstFloorLeftImagView:UIImageView?
    var firstFloorMiddleImageView:UIImageView?
    var firstFloorRightImageView:UIImageView?
    
    //创建20个按钮
    var ziCiBtn:UIButton?
    var fuHaoBtn:UIButton?
    var wenHaoBtn:UIButton?
    var douHaoJuHaoBtn:UIButton?
    var ziMuBtn:UIButton?
    var shanChuBtn:UIButton?
    var numberBtn:UIButton?
    var qiuBtn:UIButton?
    
    //定义两个按钮:保存,下一题
    var saveBtn:UIButton?
    var nextQuestionBtn:UIButton?
    
    //定义三个image
    var firstFloorLeftImage:UIImage?
    var firstFloorMiddleImage:UIImage?
    var firstFloorRightImage:UIImage?

    //定义一个变量,用于存储随机生成的数字
    var randomNumber:Int?
    
    //定义一个字符串,保存用户输入的数字
    var inputNumber:String = ""
    
    //定义一个变量,用于存储所有整数
    var suoYouZhengShu:Int = 0
    
    //定义一个变量,用于存储小键盘训练速度
    var xiaoJianPanLianXiSuDu = 0
    
    //定义一个变量,用于存储正确率
    var zhengQueLv:Double = 0.0
    
    //定义一个定时器
    var timer:Timer!
    
    //定义一个变量:保存计时器时间的值
    var timerValue:Int = 0
    
    //定义一个变量,保存"暂停开始"的状态
    var zanTingOrKaiShiStatus:Bool = false
    
    //定义一个变量,保存用户输入的数字的长度
    var inputNumberCount = 0


    override func viewDidLoad() {
        fengZhuangViewDidLoad()
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    /*
     作者:张振东
     日期:2016-10-25
     功能:封装ViewDidLoad()
     */
    func fengZhuangViewDidLoad(){
        
        //获取导航栏的高度
        navigationHeight = self.navigationController?.navigationBar.bounds.size.height
        
        self.view.backgroundColor = UIColor(red: 246,green: 246,blue: 246,alpha: 1)
        let leftBarButton = UIButton(frame:CGRect(x: 0,y: 0,width: 20,height: 20))
        leftBarButton.setBackgroundImage(UIImage(named: "fanhui"), for: UIControlState())
        leftBarButton.addTarget(self, action: #selector(backToPrevious), for: .touchUpInside)
        let leftBarButtonItem = UIBarButtonItem(customView: leftBarButton)
        self.navigationItem.leftBarButtonItems = [leftBarButtonItem]
        
        //初始化右侧的按钮
        sheZhiBtn = UIButton(frame:CGRect(x: 0, y: 0, width: 60, height: 30))
        sheZhiBtn?.setTitle("设置", for: UIControlState())
        sheZhiBtn?.setTitleColor(UIColor.white, for: UIControlState())
        sheZhiBtn!.addTarget(self,action:#selector(tiaoZhuanDaoSheZhiViewController),for:.touchUpInside)
        let rightBarButtonItem = UIBarButtonItem(customView: sheZhiBtn!)
        self.navigationItem.rightBarButtonItem = rightBarButtonItem
        
        //设置viewController上面的标题
        if let moShiLeiBie = moShiLeiBie{
            self.title = "\(moShiLeiBie)模式"
            self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
            //修改导航栏按钮颜色
            self.navigationController?.navigationBar.tintColor = UIColor.white
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha: 1)
        }
        
        //初始化三个imageView
        zanTingImageView = UIImageView(frame:CGRect(x:(screenWidth/3-30)/2,y:navigationHeight!+30,width:30,height:30))
        zanTingImageView!.contentMode = .scaleAspectFit
        let zanTingImage = UIImage(named: "zanting")
        zanTingImageView!.image = zanTingImage
        
        
        chaKanJieGuoImageView = UIImageView(frame:CGRect(x:(screenWidth/3)+(screenWidth/3-30)/2,y:navigationHeight!+30,width:30,height:30))
        chaKanJieGuoImageView!.contentMode = .scaleAspectFit
        let chaKanChengJiImage = UIImage(named: "chakanchengji")
        chaKanJieGuoImageView!.image = chaKanChengJiImage
        
        jieShuImageView = UIImageView(frame:CGRect(x:(screenWidth/3)*2+(screenWidth/3-30)/2,y:navigationHeight!+30,width:30,height:30))
        jieShuImageView!.contentMode = .scaleAspectFit
        let jieShuImage = UIImage(named: "jieshu")
        jieShuImageView!.image = jieShuImage
        
        
        //初始化两个View对象
        firstFenGeXianView = UIView(frame:CGRect(x:screenWidth/3,y:navigationHeight!+25,width:1,height:60))
        firstFenGeXianView!.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        secondFenGeXianView = UIView(frame:CGRect(x:(screenWidth/3)*2,y:navigationHeight!+25,width:1,height:60))
        secondFenGeXianView!.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化三个按钮
        zanTingBtn = UIButton(frame:CGRect(x: (screenWidth/3-80)/2,y: navigationHeight!+65,width: 80,height: 20))
        
        zanTingBtn?.setTitle("暂停", for: UIControlState())
        zanTingBtn?.setTitleColor(UIColor.black, for: UIControlState())
        zanTingBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        
        chaKanJieGuoBtn = UIButton(frame:CGRect(x: (screenWidth/3)+(screenWidth/3-80)/2,y: navigationHeight!+65,width: 80,height: 20))
        
        chaKanJieGuoBtn?.setTitle("查看结果", for: UIControlState())
        chaKanJieGuoBtn?.setTitleColor(UIColor.black, for: UIControlState())
        chaKanJieGuoBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        chaKanJieGuoBtn?.isUserInteractionEnabled = false
        
        jieShuBtn = UIButton(frame:CGRect(x: (screenWidth/3)*2+(screenWidth/3-80)/2,y: navigationHeight!+65,width: 80,height: 20))
        
        jieShuBtn?.setTitle("结束", for: UIControlState())
        
        jieShuBtn?.setTitleColor(UIColor.black, for: UIControlState())
        jieShuBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        
        //初始化横线UIView
        hengXianView = UIView(frame:CGRect(x: 10,y: navigationHeight!+90,width: screenWidth-10,height: 1))
        hengXianView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化8个UIlabel对象
        //初始化第一个UIlabel对象
        zhengQueShuLabel = UILabel(frame:CGRect(x: (screenWidth/4-60)/2,y: navigationHeight!+100,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueShuLabel!)
        
        
        //初始化第二个UIlabel对象
        zhengQueShuLabelValue = UILabel(frame:CGRect(x: (screenWidth/4-60)/2,y: navigationHeight!+120,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueShuLabelValue!)
        
        //初始化第三个UILabel对象
        zhengQueLvLabel = UILabel(frame:CGRect(x: screenWidth/4+(screenWidth/4-60)/2,y: navigationHeight!+100,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueLvLabel!)
        
        //初始化第四个UILabel对象
        zhengQueLvLabelValue = UILabel(frame:CGRect(x: screenWidth/4+(screenWidth/4-60)/2,y: navigationHeight!+120,width: 60,height: 20))
        fengZhuangLabelAttributes(zhengQueLvLabelValue!)
        
        //初始化第五个UIlabel对象
        shiJianLabel = UILabel(frame:CGRect(x: screenWidth/2+(screenWidth/4-60)/2,y: navigationHeight!+100,width: 60,height: 20))
        fengZhuangLabelAttributes(shiJianLabel!)
        
        //初始化第六个UIlabel对象
        shiJianLabelValue = UILabel(frame:CGRect(x: screenWidth/2+(screenWidth/4-60)/2,y: navigationHeight!+120,width: 60,height: 20))
        fengZhuangLabelAttributes(shiJianLabelValue!)
        
        //初始化第七个UIlabel对象
        suDuLabel = UILabel(frame:CGRect(x: (screenWidth/4)*3+(screenWidth/4-60)/2,y: navigationHeight!+100,width: 60,height: 20))
        fengZhuangLabelAttributes(suDuLabel!)
        
        //初始化第八个UIlabel对象
        suDuLabelValue = UILabel(frame:CGRect(x: (screenWidth/4)*3+(screenWidth/4-60)/2,y: navigationHeight!+120,width: 60,height: 20))
        fengZhuangLabelAttributes(suDuLabelValue!)
        
        //初始化leftView
        leftView = UIView(frame:CGRect(x:screenWidth/4,y:navigationHeight!+95,width:1,height:50))
        leftView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化middleView
        middleView = UIView(frame:CGRect(x: screenWidth/2,y:navigationHeight!+95,width:1,height:50))
        middleView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化rightView
        rightView = UIView(frame:CGRect(x: (screenWidth/4)*3,y:navigationHeight!+95,width:1,height:50))
        rightView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化第二条横线View
        secondHengXianView = UIView(frame:CGRect(x: 10,y: navigationHeight!+150,width: screenWidth-10,height: 1))
        secondHengXianView?.backgroundColor = UIColor(red: 200/255,green: 199/255,blue: 204/255,alpha: 1)
        
        //初始化4个label对象
        firstLabel = UILabel(frame:CGRect(x: 20,y: navigationHeight!+160,width: 60,height: 60))
        fengZhuangSixUiLabelAttributes(firstLabel!)
        
        secondLabel = UILabel(frame:CGRect(x: 80+(screenWidth-280)/3,y: navigationHeight!+160,width: 60,height: 60))
        fengZhuangSixUiLabelAttributes(secondLabel!)
        
        thirdLabel = UILabel(frame:CGRect(x: 140+2*(screenWidth-280)/3,y: navigationHeight!+160,width: 60,height: 60))
        fengZhuangSixUiLabelAttributes(thirdLabel!)
        
        fourthLabel = UILabel(frame:CGRect(x: screenWidth-80,y: navigationHeight!+160,width: 60,height: 60))
        fengZhuangSixUiLabelAttributes(fourthLabel!)
        
        //初始化4个UITextField对象
        firstTextFieldValue = UITextField(frame:CGRect(x: 20,y: 0,width: 60,height: 60))
        
        fengZhuangSixUiTextFieldAttributes(firstTextFieldValue!)
        
        secondTextFieldValue = UITextField(frame:CGRect(x: 80+(screenWidth-280)/3,y: 0,width: 60,height: 60))
        fengZhuangSixUiTextFieldAttributes(secondTextFieldValue!)
        
        thirdTextFieldValue = UITextField(frame:CGRect(x: 140+2*(screenWidth-280)/3,y: 0,width: 60,height: 60))
        fengZhuangSixUiTextFieldAttributes(thirdTextFieldValue!)
        
        fourthTextFieldValue = UITextField(frame:CGRect(x: screenWidth-80,y: 0,width: 60,height: 60))
        fengZhuangSixUiTextFieldAttributes(fourthTextFieldValue!)
        
        //支付宝支付密码
        inputViews = ZSDSetPasswordView(frame:CGRect(x: 0,y: navigationHeight!+230,width: screenWidth,height: 60))
        inputViews?.delegate = self
        //inputView获得焦点
        inputViews?.resignFirstResponder()
        
        //初始化键盘View
        jianPanView = UIView(frame:CGRect(x: 0, y: screenHeight-220, width: screenWidth, height: 220))
        jianPanView?.backgroundColor = UIColor(red: 209/255,green: 213/255,blue: 219/255,alpha: 1)
        jianPanView?.isUserInteractionEnabled = true
        
        //初始化第一层的三个label对象
        firstFloorLeftImagView = UIImageView(frame:CGRect(x: 0,y: 0,width: 60,height: 40))
        firstFloorLeftImage = UIImage(named: "firstFloorLeftImage.gif")
        firstFloorLeftImagView?.image = firstFloorLeftImage
        
        
        firstFloorMiddleImageView = UIImageView(frame:CGRect(x: 60,y: 0,width: screenWidth-80,height: 40))
        firstFloorMiddleImage = UIImage(named: "firstFloorMiddleImage.gif")
        firstFloorMiddleImageView?.image = firstFloorMiddleImage
        
        
        firstFloorRightImageView = UIImageView(frame:CGRect(x: screenWidth-40,y: 0,width: 40,height: 40))
        firstFloorRightImage = UIImage(named: "firstFloorRightImage.gif")
        firstFloorRightImageView?.image = firstFloorRightImage
        
        
        //初始化20个按钮
        ziCiBtn = UIButton(frame:CGRect(x: 0,y: 40+5,width: 50,height: 40))
        ziCiBtn?.setTitle("字/词", for: UIControlState())
        ziCiBtn?.setImage(UIImage(named: "ziCiImage.gif"), for: UIControlState())
        
        sevenBtn = UIButton(frame:CGRect(x: 50+5,y: 40+5,width: (screenWidth-120)/3,height: 40))
        sevenBtn?.layer.cornerRadius = 10
        sevenBtn?.backgroundColor = UIColor.white
        sevenBtn?.setTitle("7", for: UIControlState())
        sevenBtn?.isUserInteractionEnabled = true
        sevenBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        
        eightBtn = UIButton(frame:CGRect(x: 50+5*2+(screenWidth-120)/3,y: 40+5,width: (screenWidth-120)/3,height: 40))
        eightBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        eightBtn?.backgroundColor = UIColor.white
        eightBtn?.layer.cornerRadius = 10
        eightBtn?.setTitle("8", for: UIControlState())
        eightBtn?.isUserInteractionEnabled = true
        
        nineBtn = UIButton(frame:CGRect(x: 50+5*3+2*(screenWidth-120)/3,y: 40+5,width: (screenWidth-120)/3,height: 40))
        nineBtn?.titleLabel?.textColor = UIColor(red: 0,green: 0,blue: 0,alpha: 1)
        nineBtn?.backgroundColor = UIColor.white
        nineBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        
        nineBtn?.layer.cornerRadius = 10
        nineBtn?.setTitle("9", for: UIControlState())
        nineBtn?.isUserInteractionEnabled = true
        
        fuHaoBtn = UIButton(frame:CGRect(x: screenWidth-50,y: 40+5,width: 50,height: 40))
        fuHaoBtn?.setTitle("符", for: UIControlState())
        fuHaoBtn?.setImage(UIImage(named: "fuHaoImage"), for: UIControlState())
        
        wenHaoBtn = UIButton(frame:CGRect(x: 0,y: 40+5+40+5,width: 50,height: 40))
        wenHaoBtn?.setTitle("?", for: UIControlState())
        wenHaoBtn?.setImage(UIImage(named: "wenHaoImage.gif"), for: UIControlState())
        
        
        fourBtn = UIButton(frame:CGRect(x: 50+5,y: 40+5+40+5,width: (screenWidth-120)/3,height: 40))
        fourBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        fourBtn?.backgroundColor = UIColor.white
        fourBtn?.layer.cornerRadius = 10
        fourBtn?.setTitle("4", for: UIControlState())
        fourBtn?.isUserInteractionEnabled = true
        
        
        fiveBtn = UIButton(frame:CGRect(x: 50+5*2+(screenWidth-120)/3,y: 40+5+40+5,width: (screenWidth-120)/3,height: 40))
        fiveBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        fiveBtn?.backgroundColor = UIColor.white
        fiveBtn?.layer.cornerRadius = 10
        fiveBtn?.setTitle("5", for: UIControlState())
        fiveBtn?.isUserInteractionEnabled = true
        
        sixBtn = UIButton(frame:CGRect(x: 50+5*3+2*(screenWidth-120)/3,y: 40+5+40+5,width: (screenWidth-120)/3,height: 40))
        sixBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        sixBtn?.backgroundColor = UIColor.white
        sixBtn?.layer.cornerRadius = 10
        sixBtn?.setTitle("6", for: UIControlState())
        sixBtn?.isUserInteractionEnabled = true
        
        douHaoJuHaoBtn = UIButton(frame:CGRect(x: screenWidth-50,y: 40+5+40+5,width: 50,height: 40))
        douHaoJuHaoBtn?.setTitle("，。", for: UIControlState())
        douHaoJuHaoBtn?.setImage(UIImage(named: "douHaoJuHaoImage.gif"), for: UIControlState())
        
        ziMuBtn = UIButton(frame:CGRect(x: 0,y: 40+5+40+5+40+5,width: 50,height: 40))
        ziMuBtn?.setTitle("ABC", for: UIControlState())
        ziMuBtn?.setImage(UIImage(named: "ziMuImage.gif"), for: UIControlState())
        
        oneBtn = UIButton(frame:CGRect(x: 50+5,y: 40+5+40+5+40+5,width: (screenWidth-120)/3,height: 40))
        oneBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        oneBtn?.backgroundColor = UIColor.white
        oneBtn?.layer.cornerRadius = 10
        oneBtn?.setTitle("1", for: UIControlState())
        oneBtn?.isUserInteractionEnabled = true
        
        twoBtn = UIButton(frame:CGRect(x: 50+5*2+(screenWidth-120)/3,y: 40+5+40+5+40+5,width: (screenWidth-120)/3,height: 40))
        twoBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        twoBtn?.backgroundColor = UIColor.white
        twoBtn?.layer.cornerRadius = 10
        twoBtn?.setTitle("2", for: UIControlState())
        twoBtn?.isUserInteractionEnabled = true
        
        threeBtn = UIButton(frame:CGRect(x: 50+5*3+2*(screenWidth-120)/3,y: 40+5+40+5+40+5,width: (screenWidth-120)/3,height: 40))
        threeBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        threeBtn?.backgroundColor = UIColor.white
        threeBtn?.layer.cornerRadius = 10
        threeBtn?.setTitle("3", for: UIControlState())
        threeBtn?.isUserInteractionEnabled = true
        
        shanChuBtn = UIButton(frame:CGRect(x: screenWidth-50,y: 40+5+40+5+40+5,width: 50,height: 40))
        shanChuBtn?.setTitle("<", for: UIControlState())
        shanChuBtn?.setImage(UIImage(named: "qingChuImage.gif"), for: UIControlState())
        
        numberBtn = UIButton(frame:CGRect(x: 0,y: 40+5+40+5+40+5+40+5,width: 50,height: 40))
        numberBtn?.setTitle("123", for: UIControlState())
        numberBtn?.setImage(UIImage(named: "numberImage.gif"), for: UIControlState())
        
        qiuBtn = UIButton(frame:CGRect(x: 50+5,y: 40+5+40+5+40+5+40+5,width: 50,height: 40))
        qiuBtn?.setImage(UIImage(named: "qiuImage.gif"), for: UIControlState())
        
        lingBtn = UIButton(frame:CGRect(x: 50+5+50+5,y: 40+5+40+5+40+5+40+5,width: (screenWidth-120)/3,height: 40))
        lingBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        lingBtn?.backgroundColor = UIColor.white
        lingBtn?.layer.cornerRadius = 10
        lingBtn?.setTitle("0", for: UIControlState())
        lingBtn?.isUserInteractionEnabled = true
        
        saveBtn = UIButton(frame:CGRect(x: 50+5+50+5+5+(screenWidth-120)/3,y: 40+5+40+5+40+5+40+5,width: (screenWidth-120)/3,height: 40))
        saveBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        saveBtn?.backgroundColor = UIColor.white
        saveBtn?.layer.cornerRadius = 10
        saveBtn?.setTitle("空格", for: UIControlState())
        
        nextQuestionBtn = UIButton(frame:CGRect(x: 50+5+50+5+5+5+2*(screenWidth-120)/3,y: 40+5+40+5+40+5+40+5,width: (screenWidth-120)/3,height: 40))
        nextQuestionBtn?.backgroundColor = UIColor(red: 170/255,green: 170/255,blue: 170/255,alpha: 1)
        nextQuestionBtn?.setTitleColor(UIColor(red: 0,green: 0,blue: 0,alpha: 1), for: UIControlState())
        nextQuestionBtn?.layer.cornerRadius = 10
        nextQuestionBtn?.setTitle("换行", for: UIControlState())
        
        generateRandomNumber()
        jianPanView?.addSubview(firstFloorLeftImagView!)
        jianPanView?.addSubview(firstFloorMiddleImageView!)
        jianPanView?.addSubview(firstFloorRightImageView!)
        jianPanView?.addSubview(ziCiBtn!)
        jianPanView?.addSubview(sevenBtn!)
        jianPanView?.addSubview(eightBtn!)
        jianPanView?.addSubview(nineBtn!)
        jianPanView?.addSubview(fuHaoBtn!)
        jianPanView?.addSubview(wenHaoBtn!)
        jianPanView?.addSubview(fourBtn!)
        jianPanView?.addSubview(fiveBtn!)
        jianPanView?.addSubview(sixBtn!)
        jianPanView?.addSubview(douHaoJuHaoBtn!)
        jianPanView?.addSubview(ziMuBtn!)
        jianPanView?.addSubview(oneBtn!)
        jianPanView?.addSubview(twoBtn!)
        jianPanView?.addSubview(threeBtn!)
        jianPanView?.addSubview(shanChuBtn!)
        jianPanView?.addSubview(numberBtn!)
        jianPanView?.addSubview(qiuBtn!)
        jianPanView?.addSubview(lingBtn!)
        jianPanView?.addSubview(saveBtn!)
        jianPanView?.addSubview(nextQuestionBtn!)

        self.view?.addSubview(zanTingImageView!)
        self.view?.addSubview(chaKanJieGuoImageView!)
        self.view?.addSubview(jieShuImageView!)
        self.view?.addSubview(firstFenGeXianView!)
        self.view?.addSubview(secondFenGeXianView!)
        self.view?.addSubview(zanTingBtn!)
        self.view?.addSubview(chaKanJieGuoBtn!)
        self.view?.addSubview(jieShuBtn!)
        self.view?.addSubview(hengXianView!)
        self.view?.addSubview(zhengQueShuLabel!)
        self.view?.addSubview(zhengQueLvLabel!)
        self.view?.addSubview(shiJianLabel!)
        self.view?.addSubview(suDuLabel!)
        self.view?.addSubview(zhengQueShuLabelValue!)
        self.view?.addSubview(zhengQueLvLabelValue!)
        self.view?.addSubview(shiJianLabelValue!)
        self.view?.addSubview(suDuLabelValue!)
        self.view?.addSubview(leftView!)
        self.view?.addSubview(middleView!)
        self.view?.addSubview(rightView!)
        self.view?.addSubview(secondHengXianView!)
        self.view?.addSubview(firstLabel!)
        self.view?.addSubview(secondLabel!)
        self.view?.addSubview(thirdLabel!)
        self.view?.addSubview(fourthLabel!)
        self.view?.addSubview(jianPanView!)
        inputViews!.addSubview(firstTextFieldValue!)
        inputViews!.addSubview(secondTextFieldValue!)
        inputViews!.addSubview(thirdTextFieldValue!)
        inputViews!.addSubview(fourthTextFieldValue!)
        
        
        //给0、1、2、3、4、5、6、7、8、9、下一个添加点击事件
        oneBtn?.addTarget(self, action: #selector(clickOne), for: .touchUpInside)
        twoBtn?.addTarget(self, action: #selector(clickTwo), for: .touchUpInside)
        threeBtn?.addTarget(self, action: #selector(clickThree), for: .touchUpInside)
        fourBtn?.addTarget(self, action: #selector(clickFour), for: .touchUpInside)
        fiveBtn?.addTarget(self, action: #selector(clickFive), for: .touchUpInside)
        sixBtn?.addTarget(self, action: #selector(clickSix), for: .touchUpInside)
        sevenBtn?.addTarget(self, action: #selector(clickSeven), for: .touchUpInside)
        eightBtn?.addTarget(self, action: #selector(clickEight), for: .touchUpInside)
        nineBtn?.addTarget(self, action: #selector(clickNine), for: .touchUpInside)
        lingBtn?.addTarget(self, action: #selector(clickZero), for: .touchUpInside)
//        nextQuestionBtn?.addTarget(self, action: #selector(clickHuanShu), forControlEvents: .TouchUpInside)
        shanChuBtn?.addTarget(self, action: #selector(shanchudangqianshuzi), for: .touchUpInside)
        
        //分别给三个按钮添加点击事件
        zanTingBtn!.addTarget(self,action:#selector(zanTing),for:.touchUpInside)
        chaKanJieGuoBtn!.addTarget(self,action:#selector(chaKanJieGuo),for:.touchUpInside)
        jieShuBtn!.addTarget(self,action:#selector(jieShu),for:.touchUpInside)
        
        print(fenZhongZhi as Any)
        
        if let moShiCategory = moShiLeiBie{
            print(moShiCategory)
            if moShiCategory == "计时"{
                timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
            }else if moShiCategory == "定时"{
                //将传递过来的分钟值转换为秒数
                timerValue = 60 * Int(fenZhongZhi!)!
                
                timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuXuanZhongFenZhongZhiDaoJiShi), userInfo: nil, repeats: true)
            }
        }


        self.view.addSubview(inputViews!)
        
    }
    
    
    /*
     作者:张振东
     时间:2016-9-11
     功能:封装UIlabel对象的属性®
     */
    @discardableResult
    func fengZhuangLabelAttributes(_ label:UILabel) -> UILabel{
        label.font = UIFont.systemFont(ofSize: 12)
        label.textAlignment = .center
        
        switch label {
        case zhengQueShuLabel!:
            label.text = "正确数"
        case zhengQueShuLabelValue!:
            label.text = "\(zhengQueShu)"
        case zhengQueLvLabel!:
            label.text = "正确率"
        case zhengQueLvLabelValue!:
            label.text = "0%"
        case shiJianLabel!:
            label.text = "时间"
        case shiJianLabelValue!:
            label.text = "00:00:00"
        case suDuLabel!:
            label.text = "速度"
        case suDuLabelValue!:
            label.text = "0字/分钟"
            
        default: break
            
        }
        return label
    }

    
    /*
     作者:张振东
     时间:2016-9-11
     功能:封装6个UITextField对象
     */
    func fengZhuangSixUiTextFieldAttributes(_ textField:UITextField){
        textField.layer.borderWidth = 1
        textField.layer.borderColor = UIColor.orange.cgColor
        textField.textAlignment = .center
        textField.layer.cornerRadius = 30
        textField.font = UIFont.systemFont(ofSize: 25)
        textField.isUserInteractionEnabled = false
        textField.resignFirstResponder()
        textField.delegate = self
        textField.isEnabled = false
        switch textField {
        case firstTextFieldValue!:
            textField.tag = 0
            break
        case secondTextFieldValue!:
            textField.tag = 1
            break
            
        case thirdTextFieldValue!:
            textField.tag = 2
            break
            
        case fourthTextFieldValue!:
            textField.tag = 3
            break
        default:
            print("--")
        }
    }

    
    func clickOne(){
        inputNumber = inputNumber + "1"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        print(inputNumberCount)
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                           self.clickHuanShu()
                        }
                        
                        
                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
            
        }
        
    }
    
    
    func clickTwo(){
        inputNumber = inputNumber + "2"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            
                            self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"

        }

        
    }
    
    
    func clickThree(){
        inputNumber = inputNumber + "3"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                           self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"

        }

    }
    
    func clickFour(){
        inputNumber = inputNumber + "4"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                           self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"

        }

    }
    
    func clickFive(){
        inputNumber = inputNumber + "5"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"

        }

    }
    
    func clickSix(){
        inputNumber = inputNumber + "6"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                           self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"

        }

        
    }
    
    func clickSeven(){
        inputNumber = inputNumber + "7"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }

        
    }
    
    func clickEight(){
        inputNumber = inputNumber + "8"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"

        }

        
    }
    
    func clickNine(){
        inputNumber = inputNumber + "9"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"

        }

        
    }
    
    func clickZero(){
        inputNumber = inputNumber + "0"
        print(inputNumber)
        suoYouZhengShu += 1
        print(suoYouZhengShu)
        xiaoJianPanLianXiSuDu = jiSuanLianXiSuDu()
        suDuLabelValue?.text = "\(xiaoJianPanLianXiSuDu)字/分钟"
        inputNumberCount = inputNumber.characters.count
        print((inputNumber.characters.count))
        if inputNumberCount % 4 == 1{
            firstTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let firstTextFieldInputValue = firstTextFieldValue?.text{
                print(firstTextFieldInputValue)
                if let firstLabelValue = firstLabel?.text{
                    print(firstLabelValue)
                    if firstTextFieldInputValue == firstLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        firstTextFieldValue!.backgroundColor = UIColor.red
                    }
                    
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 2{
            secondTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            if let secondTextFieldInputValue = secondTextFieldValue?.text{
                print(secondTextFieldInputValue)
                if let secondLabelValue = secondLabel?.text{
                    print(secondLabelValue)
                    if secondTextFieldInputValue == secondLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        secondTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 3{
            thirdTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let thirdTextFieldInputValue = thirdTextFieldValue?.text{
                print(thirdTextFieldInputValue)
                if let thirdLabelValue = thirdLabel?.text{
                    print(thirdLabelValue)
                    if thirdTextFieldInputValue == thirdLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                    }else{
                        thirdTextFieldValue!.backgroundColor = UIColor.red
                    }
                }
            }
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
        }else if inputNumberCount % 4 == 0{
            fourthTextFieldValue?.text = (inputNumber as NSString).substring(with: NSMakeRange(inputNumberCount-1, 1))
            
            if let fourthTextFieldInputValue = fourthTextFieldValue?.text{
                print(fourthTextFieldInputValue)
                if let fourthLabelValue = fourthLabel?.text{
                    print(fourthLabelValue)
                    if fourthTextFieldInputValue == fourthLabelValue{
                        zhengQueShu += 1
                        print(zhengQueShu)
                        zhengQueShuLabelValue?.text = "\(zhengQueShu)"
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }else{
                        fourthTextFieldValue!.backgroundColor = UIColor.red
                        let time: TimeInterval = 0.1
                        let delay = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
                        DispatchQueue.main.asyncAfter(deadline: delay) {
                            self.clickHuanShu()
                        }

                    }
                }
            }
            
            let xianShiZhengQueLv = jiSuanZhengQueLv()
            zhengQueLvLabelValue?.text = "\(xianShiZhengQueLv)%"
            
        }

    }
    
    /*
     作者:张振东
     日期:2016-8-11
     功能:此方法在这里存在没有任何价值,只是为了实现ZSDSetPasswordViewDelegate协议,避免项目报错
     */
    func passwordView(_ passwordView: ZSDSetPasswordView!, inputPassword password: String!) {
    
    }
    
    
    func clickHuanShu(){
        //开始下一轮,需要将所有的数字置空
        firstTextFieldValue?.text = ""
        secondTextFieldValue?.text = ""
        thirdTextFieldValue?.text = ""
        fourthTextFieldValue?.text = ""
        
        //开始下一轮,需要将所有的前面的带颜色的textField的颜色置为白色
        firstTextFieldValue?.backgroundColor = UIColor.white
        secondTextFieldValue?.backgroundColor = UIColor.white
        thirdTextFieldValue?.backgroundColor = UIColor.white
        fourthTextFieldValue?.backgroundColor = UIColor.white
        
        //重新生成新的数字
        generateRandomNumber()
        

    }
    
    /*
     作者:张振东
     日期:2016-09-06
     功能:显示计时时间
     */
    func genJuSelectedValueJiShi(){
        timerValue += 1
        print(fenZhongZhi as Any)
        
        //获得分钟
        let fenZhongValue = timerValue/60
        //获取秒数
        let miaoValue = timerValue%60
        
        if fenZhongValue < 10 {
            if miaoValue < 10 {
                shiJianLabelValue?.text = "00:0\(fenZhongValue):0\(miaoValue)"
            }else{
                shiJianLabelValue?.text = "00:0\(fenZhongValue):\(miaoValue)"
            }
        }else{
            if miaoValue < 10{
                shiJianLabelValue?.text = "00:\(fenZhongValue):0\(miaoValue)"
            }else{
                shiJianLabelValue?.text = "00:\(fenZhongValue):\(miaoValue)"
            }
        }
        
        //当计时结束时,可以在此进行if语句中显示最终的结果
        if timerValue == Int(fenZhongZhi!)! * 60{
            timer.invalidate()
            inputViews?.isUserInteractionEnabled = false
            //在这里加一个alertController,提示计时结束
            let alertController = UIAlertController(title: "温馨提示",
                                                    message: "亲,计时时间到!", preferredStyle: UIAlertControllerStyle.alert)
            let okAction = UIAlertAction(title: "好的", style: UIAlertActionStyle.default,
                                         handler: {
                                            action in
                                            print("点击了确定")
            })
            alertController.addAction(okAction)
            self.present(alertController, animated: true, completion: nil)
            
            //当传递过来的时间消耗完毕,计时就要从0开始
            timerValue = 0
            //按钮将失去交互性,不能点击
            oneBtn?.isUserInteractionEnabled = false
            twoBtn?.isUserInteractionEnabled = false
            threeBtn?.isUserInteractionEnabled = false
            fourBtn?.isUserInteractionEnabled = false
            fiveBtn?.isUserInteractionEnabled = false
            sixBtn?.isUserInteractionEnabled = false
            sevenBtn?.isUserInteractionEnabled = false
            eightBtn?.isUserInteractionEnabled = false
            nineBtn?.isUserInteractionEnabled = false
            lingBtn?.isUserInteractionEnabled = false
            nextQuestionBtn?.isUserInteractionEnabled = false
        }
        
        print(timerValue)

    }
    
    /*
     作者:张振东
     日期:2016-09-06
     功能:显示计时时间
     */
    func genJuXuanZhongFenZhongZhiDaoJiShi(){
        print(fenZhongZhi!)
        print(timerValue)
        timerValue = timerValue - 1
        //获得分钟
        let minuteValue = timerValue/60
        //获得秒数
        let secondsValue = timerValue%60
        if minuteValue < 10{
            if secondsValue < 10{
                shiJianLabelValue?.text = "00:0\(minuteValue):0\(secondsValue)"
            }else{
                shiJianLabelValue?.text = "00:0\(minuteValue):\(secondsValue)"
            }
        }else{
            if secondsValue < 10{
                shiJianLabelValue?.text = "00:\(minuteValue):0\(secondsValue)"
            }else{
                shiJianLabelValue?.text = "00:\(minuteValue):\(secondsValue)"
            }
        }
        //当计时结束时,可以在此进行if语句中显示最终的结果
        if timerValue == 0{
            //表示倒计时结束
            timer.invalidate()
            inputViews?.isUserInteractionEnabled = false
            //在这里加一个alertController,提示倒计时结束
            let alertController = UIAlertController(title: "温馨提示",
                                                    message: "亲,倒计时结束!", preferredStyle: UIAlertControllerStyle.alert)
            
            let okAction = UIAlertAction(title: "好的", style: UIAlertActionStyle.default,
                                         handler: {
                                            action in
                                            print("点击了确定")
            })
            
            alertController.addAction(okAction)
            self.present(alertController, animated: true, completion: nil)
            
            timerValue = 0
            //按钮将失去交互性,不能点击
            oneBtn?.isUserInteractionEnabled = false
            twoBtn?.isUserInteractionEnabled = false
            threeBtn?.isUserInteractionEnabled = false
            fourBtn?.isUserInteractionEnabled = false
            fiveBtn?.isUserInteractionEnabled = false
            sixBtn?.isUserInteractionEnabled = false
            sevenBtn?.isUserInteractionEnabled = false
            eightBtn?.isUserInteractionEnabled = false
            nineBtn?.isUserInteractionEnabled = false
            lingBtn?.isUserInteractionEnabled = false
            nextQuestionBtn?.isUserInteractionEnabled = false
            print("倒计时结束!!")
        }

    }
    
    /*
     作者:张振东
     日期:2016-9-11
     功能:计算小键盘练习速度
     */
    func jiSuanLianXiSuDu() -> Int{
        print(Int(suoYouZhengShu))
        print(Int(fenZhongZhi!)!)
        let lianXiSudu = Int(suoYouZhengShu)/Int(fenZhongZhi!)!
        print(lianXiSudu)
        return lianXiSudu
    }

    /*
     作者:张振东
     时间:2016-9-11
     功能:封装6个存储随机生成的数字的Label对象
     */
    func fengZhuangSixUiLabelAttributes(_ label:UILabel){
        label.layer.borderWidth = 1
        label.layer.borderColor = UIColor.orange.cgColor
        label.textAlignment = .center
        label.layer.cornerRadius = 30
        label.font = UIFont.systemFont(ofSize: 25)
    }
    
    /*
     作者:张振东
     日期:2016-9-11
     功能:用变量存储随机生成的0-9之间的数字
     */
    func jiSuanZhengQueLv() -> Double{
        
        zhengQueLv = (Double(zhengQueShu)/Double(suoYouZhengShu))*100
        //保留小数点后两位
        let zhengQueLvZhi = String(format: "%.2f", zhengQueLv)
        print(zhengQueLvZhi)
        return Double(zhengQueLvZhi)!
    }

    
    /*
     作者:张振东
     日期:2016-9-11
     功能:用变量存储随机生成的0-9之间的数字
     */
    func generateRandomNumber(){
        for index in 0...4 {
            if index == 0{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    firstLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 1{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    secondLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 2{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    thirdLabel?.text = "\(randomNumber)"
                }
                
            }else if index == 3{
                randomNumber = Int(arc4random_uniform(10))
                if let randomNumber = randomNumber{
                    fourthLabel?.text = "\(randomNumber)"
                }
            }
        }
    }


    /*
     作者:张振东
     时间:2016-9-28
     功能:禁用系统键盘
     */
    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        textField.isEnabled = false
        return false
    }

    /*
     作者:张振东
     日期:2016-09-11
     功能:当用户点击暂停时所作的操作
     1、所有的textFieldValue失去交互性
     2、将上面的正确数、正确率、时间、速度保存在本地
     3、暂停两个字修改为开始
     4、让时间失去交互性
     */
    func zanTing(){
        print("暂停按钮被点击")
        //点击暂停之后,查看结果的按钮才具有交互性
        chaKanJieGuoBtn?.isUserInteractionEnabled = true
        
        zanTingBtn?.isSelected = !(zanTingBtn?.isSelected)!
        print(zanTingBtn?.isSelected as Any)
        zanTingOrKaiShiStatus = (zanTingBtn?.isSelected)!
        if zanTingBtn?.isSelected == true{
            //1、所有的textFieldValue失去交互性
            firstTextFieldValue?.isUserInteractionEnabled = false
            secondTextFieldValue?.isUserInteractionEnabled = false
            thirdTextFieldValue?.isUserInteractionEnabled = false
            fourthTextFieldValue?.isUserInteractionEnabled = false
            inputViews?.isUserInteractionEnabled = false
            
            //按钮将失去交互性,不能点击
            oneBtn?.isUserInteractionEnabled = false
            twoBtn?.isUserInteractionEnabled = false
            threeBtn?.isUserInteractionEnabled = false
            fourBtn?.isUserInteractionEnabled = false
            fiveBtn?.isUserInteractionEnabled = false
            sixBtn?.isUserInteractionEnabled = false
            sevenBtn?.isUserInteractionEnabled = false
            eightBtn?.isUserInteractionEnabled = false
            nineBtn?.isUserInteractionEnabled = false
            lingBtn?.isUserInteractionEnabled = false
            nextQuestionBtn?.isUserInteractionEnabled = false
            
            //2、将上面的正确数、正确率、时间、速度保存在本地
            UserDefaults.standard.set(zhengQueShu, forKey: "zhengQueShuInt")
            UserDefaults.standard.set(zhengQueLv, forKey: "zhengQueLv")
            UserDefaults.standard.set(timerValue, forKey: "timerValue")
            UserDefaults.standard.set(xiaoJianPanLianXiSuDu, forKey: "xiaoJianPanLianXiSuDu")
        
            UserDefaults.standard.synchronize()
            
            //暂停两个字修改为开始
            zanTingBtn?.setTitle("开始", for: UIControlState())
            //暂停的按钮修改为开始按钮
            let kaiShiImage = UIImage(named: "begin")
            zanTingImageView!.image = kaiShiImage
            zanTingBtn?.setTitleColor(UIColor.gray, for: UIControlState())
            //让时间失去交互性
            timer.invalidate()
        }else{
            inputViews?.isUserInteractionEnabled = true
            
            //按钮获得交互性
            oneBtn?.isUserInteractionEnabled = true
            twoBtn?.isUserInteractionEnabled = true
            threeBtn?.isUserInteractionEnabled = true
            fourBtn?.isUserInteractionEnabled = true
            fiveBtn?.isUserInteractionEnabled = true
            sixBtn?.isUserInteractionEnabled = true
            sevenBtn?.isUserInteractionEnabled = true
            eightBtn?.isUserInteractionEnabled = true
            nineBtn?.isUserInteractionEnabled = true
            lingBtn?.isUserInteractionEnabled = true
            nextQuestionBtn?.isUserInteractionEnabled = true
            
            //让暂停恢复原状
            zanTingBtn?.setTitle("暂停", for: UIControlState())
            let zanTingImage = UIImage(named: "zanting")
            zanTingImageView!.image = zanTingImage
            zanTingBtn?.setTitleColor(UIColor.black, for: UIControlState())
            
            //当开始的时候,查看结果按钮是不具有交互性的
            chaKanJieGuoBtn?.isUserInteractionEnabled = false
            
            if let moShiCategory = moShiLeiBie{
                print(moShiCategory)
                if moShiCategory == "计时"{
                    if timer != nil{
                        timer.invalidate()
                        timer = nil
                    }
                    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
                }else if moShiCategory == "定时"{
                    if timer != nil{
                        timer.invalidate()
                        timer = nil
                    }
                    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuXuanZhongFenZhongZhiDaoJiShi), userInfo: nil, repeats: true)
                }
            }
        }
    }
    
    /*
     作者:张振东
     日期:2016-09-06
     功能:跳转至另一个界面,显示训练结果
     1、跳转至查看结果的界面
     2、将值传递过去
     */
    func chaKanJieGuo(){
        let chaKanJieGuoViewController = ChaKanJieGuoViewController()
        if let moShiCategory = moShiLeiBie{
            print(moShiCategory)
            chaKanJieGuoViewController.moShiCategory = moShiCategory
            chaKanJieGuoViewController.miniteValue = Int(fenZhongZhi!)!
        }
        self.navigationController?.pushViewController(chaKanJieGuoViewController, animated: true)
        
    }
    
    /*
     作者:张振东
     日期:2016-09-06
     功能:训练结束
     1、时间失效
     2、4个textFieldValue失效
     3、几个按钮实效
     4、查看结果按钮获得交互性
     */
    func jieShu(){
        //1、时间失效
        timer.invalidate()
        
        //2、4个textFieldValue失效
        firstTextFieldValue?.isUserInteractionEnabled = false
        secondTextFieldValue?.isUserInteractionEnabled = false
        thirdTextFieldValue?.isUserInteractionEnabled = false
        fourthTextFieldValue?.isUserInteractionEnabled = false
        
        
        //3、按钮将失去交互性,不能点击
        oneBtn?.isUserInteractionEnabled = false
        twoBtn?.isUserInteractionEnabled = false
        threeBtn?.isUserInteractionEnabled = false
        fourBtn?.isUserInteractionEnabled = false
        fiveBtn?.isUserInteractionEnabled = false
        sixBtn?.isUserInteractionEnabled = false
        sevenBtn?.isUserInteractionEnabled = false
        eightBtn?.isUserInteractionEnabled = false
        nineBtn?.isUserInteractionEnabled = false
        lingBtn?.isUserInteractionEnabled = false
        nextQuestionBtn?.isUserInteractionEnabled = false
        
        //4、查看结果具有交互性
        chaKanJieGuoBtn?.isUserInteractionEnabled = true
        
        //5、将值保存下来:经测试,保存成功
        UserDefaults.standard.set(zhengQueShu, forKey: "zhengQueShuInt")
        UserDefaults.standard.set(zhengQueLv, forKey: "zhengQueLv")
        UserDefaults.standard.set(timerValue, forKey: "timerValue")
        UserDefaults.standard.set(xiaoJianPanLianXiSuDu, forKey: "xiaoJianPanLianXiSuDu")
    }
    
    /*
     作者:张振东
     时间:2016-9-15
     功能:设置结束之后在原来的基础上进行计时
     */
    func chuanDiFenZhongZhiDaoXiaoJianPan(_ fenZhongZhi: Int) {
        timerValue = fenZhongZhi
        if timer != nil{
            timer.invalidate()
            timer = nil
        }
        timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
    }

    
    /*
     作者:张振东
     时间:2016-9-11
     功能:实现跳转至设置界面的ViewController功能
     */
    func tiaoZhuanDaoSheZhiViewController(){
        timer.invalidate()
        print(timerValue)
        let sheZhiLabelYangShiViewController = SheZhiLabelYangShiViewController()
        sheZhiLabelYangShiViewController.delegate = self
        UserDefaults.standard.set(timerValue, forKey: "timerValue")
        
        
        //将传递过来的分钟值传递到下一个ViewController
        sheZhiLabelYangShiViewController.xuanZhongDeFenZhongValue = fenZhongZhi
        print(sheZhiLabelYangShiViewController.xuanZhongDeFenZhongValue as Any)
        sheZhiLabelYangShiViewController.zanTingOrKaiShiStatus = zanTingOrKaiShiStatus
        self.navigationController?.pushViewController(sheZhiLabelYangShiViewController, animated: true)
    }
    
    
    func chuanDiXuanZhongFenZhongZhiDaoXiaoJianPan(_ xuanZhongDeFenZhongValueJieBao: Int) {
        print(xuanZhongDeFenZhongValueJieBao)
        fenZhongZhi = String(xuanZhongDeFenZhongValueJieBao)
        print(fenZhongZhi as Any)
    }

    //获得传递过来的暂停按钮的状态
    func chuanDiZanTingOrkaiShiStatus(_ zanTingOrKaiShiStatus: Bool) {
        //表示暂停状态,这是计时器不走
        if zanTingOrKaiShiStatus == true{
            if timer != nil{
                timer.invalidate()
                timer = nil
            }
        }else{
            //表示为开始状态
            if timer != nil{
                timer.invalidate()
                timer = nil
            }
            if let moShiCategory = moShiLeiBie{
                print(moShiCategory)
                if moShiCategory == "计时"{
                    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuSelectedValueJiShi), userInfo: nil, repeats: true)
                }else if moShiCategory == "定时"{
                    //将传递过来的分钟值转换为秒数
                    timerValue = 60 * Int(fenZhongZhi!)!
                    
                    timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(genJuXuanZhongFenZhongZhiDaoJiShi), userInfo: nil, repeats: true)
                }
            }

            
        }
    }
    
    /*
     作者:张振东
     日期:2016-09-17
     功能:接收传递过来的indexPathDianRow
     */
    func chuanDiIndexPathDianRow(_ indexPathDianRow: Int) {
        self.indexPathDianRow = indexPathDianRow
        switch indexPathDianRow {
        case 0:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 130/255,blue: 171/255,alpha: 1).cgColor

            break
        case 1:
            
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 174/255,blue: 185/255,alpha: 1).cgColor
            
            break
        case 2:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
        
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 218/255,blue: 185/255,alpha: 1).cgColor
            
            break
        case 3:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 255/255,green: 106/255,blue: 106/255,alpha: 1).cgColor
            
            break
            
        case 4:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 238/255,green: 216/255,blue: 174/255,alpha: 1).cgColor
            
            break
        case 5:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 220/255,green: 220/255,blue: 220/255,alpha: 1).cgColor
            
            break
            
        case 6:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 72/255,green: 209/255,blue: 204/255,alpha: 1).cgColor
            
            break
        case 7:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 124/255,green: 252/255,blue: 0/255,alpha: 1).cgColor
            
            break
            
        case 8:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 189/255,green: 183/255,blue: 107/255,alpha: 1).cgColor
            break
        case 9:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 244/255,green: 164/255,blue: 96/255,alpha: 1).cgColor
            break
            
        case 10:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 240/255,green: 128/255,blue: 128/255,alpha: 1).cgColor
            
            break
        case 11:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 188/255,green: 143/255,blue: 143/255,alpha: 1).cgColor
            break
            
        case 12:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 143/255,green: 188/255,blue: 143/255,alpha: 1).cgColor
            break
        case 13:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 64/255,green: 224/255,blue: 208/255,alpha: 1).cgColor
            
            break
            
        case 14:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
          
            
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 0/255,green: 139/255,blue: 139/255,alpha: 1).cgColor
            
            break
        case 15:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1)
            
            //设置UILabel边框的颜色
            firstLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            secondLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            thirdLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            fourthLabel?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            //设置UItextField边框的颜色
            firstTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            secondTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            thirdTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            fourthTextFieldValue?.layer.borderColor = UIColor(red: 34/255,green: 139/255,blue: 34/255,alpha: 1).cgColor
            break
            
        case 16:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
            break
        default:
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
        }
    }

    
    func chuanDiXuanZhongFenZhongValueAndBianKuangXingZhuang(_ xuanZhongFenZhongValue: Int, indexPathDianRow: Int) {
        print(xuanZhongFenZhongValue)
        print(indexPathDianRow)
        bianKuangXingZhuangIndexPathDianRow = indexPathDianRow
        switch bianKuangXingZhuangIndexPathDianRow {
        case 0:
            //将UILabel和UItextField的边框修改为正方形
            firstLabel?.layer.cornerRadius = 0
            secondLabel?.layer.cornerRadius = 0
            thirdLabel?.layer.cornerRadius = 0
            fourthLabel?.layer.cornerRadius = 0
            
            firstTextFieldValue?.layer.cornerRadius = 0
            secondTextFieldValue?.layer.cornerRadius = 0
            thirdTextFieldValue?.layer.cornerRadius = 0
            fourthTextFieldValue?.layer.cornerRadius = 0
           
            
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
            break
        case 1:
            //将UILabel和UItextField的边框修改为圆方形
            firstLabel?.layer.cornerRadius = 30
            secondLabel?.layer.cornerRadius = 30
            thirdLabel?.layer.cornerRadius = 30
            fourthLabel?.layer.cornerRadius = 30
          
            
            firstTextFieldValue?.layer.cornerRadius = 30
            secondTextFieldValue?.layer.cornerRadius = 30
            thirdTextFieldValue?.layer.cornerRadius = 30
            fourthTextFieldValue?.layer.cornerRadius = 30
           
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
            break
        default:
            print("default")
            //设置导航栏的颜色
            self.navigationController?.navigationBar.barTintColor =
                UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha:1)
        }
    }

    /*
     作者:张振东
     日期:2016-12-04
     功能:点击删除按钮,将当前的输入的数字删除
     */
    func shanchudangqianshuzi(){
        if inputNumber.characters.count % 4 == 1{
            firstTextFieldValue?.text = ""
            inputNumber = ""
            inputNumberCount = inputNumberCount - 1
            print(inputNumberCount)
        }else if inputNumber.characters.count % 4 == 2{
            secondTextFieldValue?.text = ""
            inputNumber = firstTextFieldValue!.text! + ""
            inputNumberCount = inputNumberCount - 1
            print(inputNumberCount)
        }else if inputNumber.characters.count % 4 == 3{
            thirdTextFieldValue?.text = ""
            inputNumber = firstTextFieldValue!.text! + secondTextFieldValue!.text! + ""
            inputNumberCount = inputNumberCount - 1
            print(inputNumberCount)
        }
    }

    
    //返回至上一个界面
    func backToPrevious(){
        self.navigationController?.popViewController(animated: true)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
